﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace antyspam_filter
{
    public class EmailParser
    {
        private EmailHeader _header;
        private EmailBody _body;

        public EmailHeader Header 
        {
            get
            {
                return this._header;
            }
        }
        public EmailBody Body 
        {
            get
            {
                return this._body;
            }
        }

        public EmailParser(string content)
        {
            string[] temp = content.Split(new string[] { "\r\n\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            
            this._header = new EmailHeader(temp[0]);
            this._body = new EmailBody(String.Join("", temp.Skip(1).ToArray()));

        }

        public override string ToString()
        {
            return "HEADER\r\n " + this._header.ToString() + "\r\nBODY\r\n" + this._body.ToString();
        }
    }
}
